<template>
	<!-- 添加验收总结 -->
  <view class="flex-col page">
    <view class="flex-col group">
      <view class="flex-col group_1">
		  <view class="flex-row u-col-center hgl" >
			  <text class="text_1">合格率：</text>
			  <input type="text" v-model="fen">
			 <text class="u-font-24">%</text>
		  </view>
        
        <view class="flex-row group_2">
          <text class="text_2">验收质量：</text>
          <uni-rate :size="21" v-model="rate" @change="onChange"/>
        </view>
        <text class="text_3">总体质量描述：</text>
        <view class="flex-col list-item">
			<view class="flex-col items-start text-wrapper">
			  <textarea name="" id="" cols="30" rows="10" placeholder="请输入回复内容…" class="text_4" v-model="replayOne"></textarea>
			</view>
          <view class=" group_3">
          <shop-upload :maxCount="9" :fileList="fileList1" @del="delectPic" @success='success'></shop-upload>
          </view>
          <text class="text_6">质量问题严重程度总括：</text>
        </view>
        <view class="flex-col list-item_1">
			<view class="flex-col items-start text-wrapper">
			  <textarea name="" id="" cols="30" rows="10" placeholder="请输入回复内容…" class="text_4" v-model="replayTwo"></textarea>
			</view>
          <view class=" group_3">
          <shop-upload :maxCount="9" :fileList="fileList2" @del="delectPic2" @success='success2'></shop-upload>
          </view>
          <text class="text_8">整改建议及相关的图片：</text>
        </view>
        <view class="flex-col list-item_2">
          <view class="flex-col items-start text-wrapper">
			  <textarea name="" id="" cols="30" rows="10" placeholder="请输入回复内容…" class="text_4" v-model="replayThree"></textarea>
		  </view>
          <view class=" group_4">
           <shop-upload :maxCount="9" :fileList="fileList3" @del="delectPic3" @success='success3'></shop-upload>
          </view>
        </view>
      </view>
      <view class="flex-col items-center button"><text class="text_10" @click="sure">确认</text></view>
    </view>
  </view>
</template>

<script>
  export default {
    components: {},
    data() {
      return {
		  fileList1: [],
		  fileList2: [],
		  fileList3: [],
		  Qualified:'',
		  replayThree:'',
		  replayTwo:'',
		  replayOne:'',
		  acceptanceServiceId:'',
		  rate:5,
		  ordersId:0,
		  fen:0,
	  };
    },
	onLoad(option) {
		this.acceptanceServiceId = option.acceptanceServiceId
		this.ordersId = option.ordersId
		this.getFen(this.ordersId)
		this.rate = option.rate
	},
	created() {
		uni.startPullDownRefresh();
		setTimeout(function() {
			uni.stopPullDownRefresh();
		}, 1000);
	},
    methods: {
		getFen(ordersId)
		{
		  this.$http('other.ordersidQualified',{
			  ordersId:ordersId
		  }).then(r=>{
			 if(r.code==200)
			 {
				 this.fen=r.data;
			 }
		  });	
		},
		onChange(e)
		{
			this.rate=e.value;
		},
		delectPic(index){
			this.fileList1.splice(index,1);
		},
		success(file){
			this.fileList1.push({url:file.url})
			console.log(this.fileList1);
		},
		delectPic2(index){
			this.fileList2.splice(index,1);
		},
		success2(file){
			this.fileList2.push({url:file.url})
			console.log(this.fileList2);
		},
		delectPic3(index){
			this.fileList3.splice(index,1);
		},
		success3(file){
			this.fileList3.push({url:file.url})
			console.log(this.fileList);
		},
		sure(){
			if(this.fileList1.length==0)
			{
				this.$u.toast('请上传设计图纸');
				return;
			}
			let arr=[];
			this.fileList1.map(item=>{
				arr.push(item.url)
			})
			let overviewConstructionUrl;
			if(arr.length<=1){
				overviewConstructionUrl=arr[0];
			}else{
				overviewConstructionUrl=arr.join(",");
			}
			let arr2=[];
			this.fileList2.map(item=>{
				arr2.push(item.url)
			})
			let sumQualityPicture;
			if(arr2.length<=1){
				sumQualityPicture=arr2[0];
			}else{
				sumQualityPicture=arr2.join(",");
			}
			let arr3=[];
			this.fileList3.map(item=>{
				arr3.push(item.url)
			})
			let rectificationPicture;
			if(arr3.length<=1){
				rectificationPicture=arr3[0];
			}else{
				rectificationPicture=arr3.join(",");
			}
			
			if(this.fen ==''){
				uni.showToast({
					title:'请输入合格率',
					icon:'error'
				})
				return;
			}
			
			this.$http('version.saveYSZJ',{
				acceptanceServiceId:this.acceptanceServiceId,
				quality:this.rate,//验收质量
				qualified:this.fen,//合格率
				sumQualityDescribe:this.replayOne,//总体质量描述
				sumQualityPicture:sumQualityPicture,//总体质量图片
				sumProblemDescribe:this.replayTwo,//质量问题严重程度总结
				sumProblemPicture:overviewConstructionUrl,//质量问题严重程度总结图片
				rectificationDescribe:this.replayThree,//整改建议描述
				rectificationPicture:rectificationPicture//整改建议图片
				
			}).then(res=>{
				// console.log(res,'保存验收总结')
				if(res.code==200){
					// this.$u.toast('保存成功');
					uni.navigateTo({
						url:'pages/onSite/onSiteIndex/checkEx/checkEx'
					})
				}else{
					this.$u.toast(res.msg);
				}
			})
			
			
		},
		
	},
  };
</script>

<style scoped lang="scss">
	.hgl input{
		color: #1d6aff;
		font-size: 36rpx;
		width: 80rpx;
		text-align: right;
	}
  .image_1 {
    width: 26rpx;
    height: 25rpx;
  }
  .image_5 {
    width: 32rpx;
    height: 32rpx;
  }
  .text-wrapper {
    padding: 23rpx 0;
    border-radius: 16rpx;
    background-image: url($IMG_URL+'16557870924533882008.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
  }
  .group_3 {
    padding: 31rpx 0 40rpx;
    border-bottom: solid 1rpx #eeeeee;
    position: relative;
  }
  .image_8 {
    border-radius: 16rpx;
    position: absolute;
    left: 1rpx;
    top: 31rpx;
    width: 214rpx;
    height: 214rpx;
  }
  .image_10 {
    width: 214rpx;
    height: 214rpx;
  }
  .text_4 {
    // margin-left: 25rpx;
    // color: #999999;
    font-size: 28rpx;
    font-family: '.AppleSystemUIFont';
    line-height: 33rpx;
	// border: 1px solid #EEEEEE;
	border-radius: 28rpx;
	padding: 15rpx;
  }
  .page {
    background-color: #ffffffff;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
  }
  .group {
    padding: 0 31rpx 48rpx;
    flex: 1 1 auto;
    overflow-y: auto;
  }
  .group_1 {
    padding: 35rpx 0;
  }
  .button {
    margin-top: 45rpx;
    padding: 19rpx  31rpx;
    background-color: #1d6aff;
    border-radius: 44rpx;
  }
  .text_1 {
    align-self: flex-start;
    color: #1d6aff;
    font-size: 32rpx;
    font-family: '.AppleSystemUIFont';
    line-height: 50rpx;
  }
  .group_2 {
    margin-top: 32rpx;
  }
  .text_3 {
    margin-top: 35rpx;
    align-self: flex-start;
    color: #191919;
    font-size: 32rpx;
    font-family: '.AppleSystemUIFont';
    line-height: 38rpx;
	font-weight: 600;
  }
  .list-item {
    margin-top: 35rpx;
  }
  .list-item_1 {
    margin-top: 35rpx;
  }
  .list-item_2 {
    margin-top: 35rpx;
  }
  .text_10 {
    color: #ffffff;
    font-size: 32rpx;
    font-family: '.AppleSystemUIFont';
  
  }
  .text_2 {
    margin-bottom: 4rpx;
    color: #666666;
    font-size: 32rpx;
    font-family: '.AppleSystemUIFont';
    line-height: 38rpx;
  }
  .image_2 {
    margin-left: 11rpx;
    margin-top: 14rpx;
	width: 214rpx;
	height: 214rpx;
  }
  .image_3 {
    margin-left: 8rpx;
    margin-top: 14rpx;
  }
  .image_4 {
    margin-left: 6rpx;
    margin-top: 14rpx;
  }
  .image_6 {
    margin-left: 5rpx;
  }
  .image_7 {
    
  }
  .text_6 {
    margin-top: 37rpx;
    align-self: flex-start;
    color: #191919;
    font-size: 32rpx;
    font-family: '.AppleSystemUIFont';
    line-height: 38rpx;
	font-weight: 600;
  }
  .text_8 {
    margin-top: 37rpx;
    align-self: flex-start;
    color: #191919;
    font-size: 32rpx;
    font-family: '.AppleSystemUIFont';
    line-height: 38rpx;
	font-weight: 600;
  }
  .group_4 {
    padding-top: 31rpx;
    position: relative;
  }
  .image_14 {
    border-radius: 16rpx;
    position: absolute;
    left: 1rpx;
    bottom: 0;
    width: 214rpx;
    height: 214rpx;
  }
</style>